package com.winsun.hellozookeeper.client;

import com.winsun.hellozookeeper.service.HelloService;

import javax.naming.Context;
import javax.naming.InitialContext;

public class Client {
    private String serverHost;

    public Client(String serverHost) {
        this.serverHost = serverHost;
        try {
            //初始化命名内容
            Context context= new InitialContext();
            //注册对象
            HelloService service=(HelloService) context.lookup("rmi://"+serverHost+":1888/helloService");
            String result=service.sayHello("winsun");
            System.out.println(result+"来自："+serverHost);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Client("192.168.85.117");
    }
}
